using System;
using Bookvar.ObjectModel;
using Bookvar.ObjectModel.Actions.Collaboration;
using Bookvar.ObjectModel.Collections;

namespace Bookvar.Collaboration.ServerSide
{
    internal interface ICollaborationUsersManager
    {
        /// <summary>
        /// Gets the collaboration users, including the host. This collection is intended to be readonly.
        /// </summary>
        /// <value>The collaboration users.</value>
        CollaborationUserCollection CollaborationUsers { get; }

        /// <summary>
        /// Gets the host.
        /// </summary>
        /// <value>The host.</value>
        CollaborationUser Host { get; }

        /// <summary>
        /// Adds the provided user and the callback associated with it.
        /// </summary>
        /// <exception cref="InvalidOperationException">
        /// if the user id or name are already used.
        /// </exception>
        /// <param name="user">The user.</param>
        /// <param name="callback">The callback.</param>
        void AddUser(CollaborationUser user, ICollaborationServiceCallback callback);

        /// <summary>
        /// Determines whether the specified user name is free to use.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns>
        /// 	<c>true</c> if the specified name is free; otherwise, <c>false</c>.
        /// </returns>
        bool IsUserNameFree(string name);

        /// <summary>
        /// Determines whether the specified user id is free to use.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns>
        /// 	<c>true</c> if user id is free to use; otherwise, <c>false</c>.
        /// </returns>
        bool IsUserIdFree(Guid id);

        /// <summary>
        /// Generates the new user.
        /// </summary>
        /// <param name="name">Name of the user.</param>
        /// <returns></returns>
        CollaborationUser GenerateNewUser(string name);

        /// <summary>
        /// Informs the collaboration users that an user joined.
        /// </summary>
        /// <param name="user">The user.</param>
        void InformUserJoined(CollaborationUser user);

        /// <summary>
        /// Informs the collaboration users to process the action.
        /// </summary>
        /// <param name="action">The action.</param>
        void InformProcessAction(ActionBase action);

        /// <summary>
        /// Informs the collaboration users that the server is closed.
        /// </summary>
        void InformServerClosed();

        void UserLeaves(CollaborationUser client);

        event EventHandler<CollaborationUserEventArgs> UserJoined;

        event EventHandler<CollaborationUserEventArgs> UserLeft;
    }
}